﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Castle.Windsor;
using Castle.Windsor.Installer;
using Managistics.Core.Dependencies;
using Managistics.Warehouse.Controllers.Interfaces;
using Managistics.Warehouse.Views.Purchases;
using Managistics.Warehouse.Views.Sales;
using Managistics.Warehouse.Views.Inventory;
using Managistics.Warehouse.Views;

namespace Managistics.Warehouse
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            try
            {
                log4net.Config.XmlConfigurator.Configure();

                using (var container = new WindsorContainer().Install(FromAssembly.This()))
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    // install the dependency installers from core package
                    container.Install(FromAssembly.Containing<WarehouseDependencyInstaller>());

                    // call to return a controller object by key
                    var mainController = container.Resolve<IMainController>();
                    // run controller to show main dialog
                    mainController.Run();

                    container.Release(mainController);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }

            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new SubForm());
        }
    }
}
